libldap-symbol-versions
authorDebian OpenLDAP Maintainers <pkg-openldap-devel@lists.alioth.debian.org>
Sun, 16 Jul 2017 19:57:41 +0000 (20:57 +0100)
committerRyan Tandy <ryan@nardis.ca>
Sun, 16 Jul 2017 19:57:41 +0000 (20:57 +0100)
Add symbol versioning to the public LDAP libraries.  This is required for
library transitions, such as the current transition from 2.1 to 2.4,
since programs will sometimes have both libraries loaded by different
dependency chains during the transition.

Not yet contributed upstream.

Upstream ITS #5365 filed requesting symbol versioning for libldap and
libber.

Gbp-Pq: Name libldap-symbol-versions

build/openldap.m4
build/top.mk
configure.in
libraries/liblber/Makefile.in
libraries/liblber/liblber.map [new file with mode: 0644]
libraries/libldap/Makefile.in
libraries/libldap/libldap.map [new file with mode: 0644]
libraries/libldap_r/Makefile.in

index 37c20d0fe76d5f0630840c2d0ac5292af217c5f3..c162e16ff42a562918422fca902f8db003aa1738 100644 (file)
@@ -1142,3 +1142,54 @@ AC_DEFUN([OL_SSL_COMPAT],
 #endif
        ], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])
 ])
+
+dnl ====================================================================
+dnl check for symbol versioning support
+AC_DEFUN([OL_SYMBOL_VERSIONING],
+[AC_CACHE_CHECK([for .symver assembler directive],
+       [ol_cv_asm_symver_directive],[
+cat > conftest.s <<EOF
+${libc_cv_dot_text}
+_sym:
+.symver _sym,sym@VERS
+EOF
+if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+  ol_cv_asm_symver_directive=yes
+else
+  ol_cv_asm_symver_directive=no
+fi
+rm -f conftest*])
+AC_CACHE_CHECK([for ld --version-script],
+       [ol_cv_ld_version_script_option],[
+if test $ol_cv_asm_symver_directive = yes; then
+  cat > conftest.s <<EOF
+${libc_cv_dot_text}
+_sym:
+.symver _sym,sym@VERS
+EOF
+  cat > conftest.map <<EOF
+VERS_1 {
+       global: sym;
+};
+
+VERS_2 {
+       global: sym;
+} VERS_1;
+EOF
+  if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+    if AC_TRY_COMMAND([${CC-cc} $CFLAGS $LDFLAGS -shared
+                                                 -o conftest.so conftest.o
+                                                 -Wl,--version-script,conftest.map
+                       1>&AS_MESSAGE_LOG_FD]);
+    then
+      ol_cv_ld_version_script_option=yes
+    else
+      ol_cv_ld_version_script_option=no
+    fi
+  else
+    ol_cv_ld_version_script_option=no
+  fi
+else
+  ol_cv_ld_version_script_option=no
+fi
+rm -f conftest*])])
index 1dc588c1156b3648dd3d0e4710a4312524c4e085..7aa84f202008ab49d9bd55b3e267369a07b515ae 100644 (file)
@@ -104,6 +104,9 @@ LTFLAGS_MOD = $(@PLAT@_LTFLAGS_MOD)
 # LINK_LIBS referenced in library and module link commands.
 LINK_LIBS = $(MOD_LIBS) $(@PLAT@_LINK_LIBS)
 
+# option to pass to $(CC) to support library symbol versioning, if any
+VERSION_OPTION = @VERSION_OPTION@
+
 LTSTATIC = @LTSTATIC@
 
 LTLINK   = $(LIBTOOL) --mode=link \
@@ -113,7 +116,7 @@ LTCOMPILE_LIB = $(LIBTOOL) $(LTONLY_LIB) --mode=compile \
        $(CC) $(LT_CFLAGS) $(LT_CPPFLAGS) $(LIB_DEFS) -c
 
 LTLINK_LIB = $(LIBTOOL) $(LTONLY_LIB) --mode=link \
-       $(CC) $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS_LIB)
+       $(CC) $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS_LIB) $(VERSION_FLAGS)
 
 LTCOMPILE_MOD = $(LIBTOOL) $(LTONLY_MOD) --mode=compile \
        $(CC) $(LT_CFLAGS) $(LT_CPPFLAGS) $(MOD_DEFS) -c
index 15c0dfcc7e3286cc4a752b38365e254e15e92ff9..ddee98868d05a4456594301707d798e88742ac04 100644 (file)
@@ -1916,6 +1916,13 @@ else
 fi
 AC_SUBST(LTSTATIC)dnl
 
+VERSION_OPTION=""
+OL_SYMBOL_VERSIONING
+if test $ol_cv_ld_version_script_option = yes ; then
+  VERSION_OPTION="-Wl,--version-script="
+fi
+AC_SUBST(VERSION_OPTION)
+
 dnl ----------------------------------------------------------------
 if test $ol_enable_wrappers != no ; then
        AC_CHECK_HEADERS(tcpd.h,[
index 779ed9d0aba1eadc2c6577e95459d78ce8f9df76..b417659ae8dcd6f0972019b47e49227edb04f203 100644 (file)
@@ -38,6 +38,9 @@ XLIBS = $(LIBRARY) $(LDAP_LIBLUTIL_A)
 XXLIBS = 
 NT_LINK_LIBS = $(AC_LIBS)
 UNIX_LINK_LIBS = $(AC_LIBS)
+ifneq (,$(VERSION_OPTION))
+  VERSION_FLAGS = "$(VERSION_OPTION)$(srcdir)/liblber.map"
+endif
 
 dtest:    $(XLIBS) dtest.o
        $(LTLINK) -o $@ dtest.o $(LIBS)
diff --git a/libraries/liblber/liblber.map b/libraries/liblber/liblber.map
new file mode 100644 (file)
index 0000000..b54853c
--- /dev/null
@@ -0,0 +1,8 @@
+OPENLDAP_2.4_2 {
+  global:
+    ber_*;
+    der_alloc;
+    lutil_*;
+  local:
+    *;
+};
index 0b3242509418acdb1ef80fc30352d7046177f472..240c005f20b2c6fd08a8c5baf82c926e6802341e 100644 (file)
@@ -52,6 +52,9 @@ XLIBS = $(LIBRARY) $(LDAP_LIBLBER_LA) $(LDAP_LIBLUTIL_A)
 XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS)
 NT_LINK_LIBS = $(LDAP_LIBLBER_LA) $(AC_LIBS) $(SECURITY_LIBS)
 UNIX_LINK_LIBS = $(LDAP_LIBLBER_LA) $(AC_LIBS) $(SECURITY_LIBS)
+ifneq (,$(VERSION_OPTION))
+  VERSION_FLAGS = $(VERSION_OPTION)$(srcdir)/libldap.map
+endif
 
 apitest:       $(XLIBS) apitest.o
        $(LTLINK) -o $@ apitest.o $(LIBS)
diff --git a/libraries/libldap/libldap.map b/libraries/libldap/libldap.map
new file mode 100644 (file)
index 0000000..605dcff
--- /dev/null
@@ -0,0 +1,7 @@
+OPENLDAP_2.4_2 {
+  global:
+    ldap_*;
+    ldif_*;
+  local:
+    *;
+};
index 29589d9040e076aa907f75b7e3bab93209efeac7..9d3bdb47883c895bc4f84734eab8bdcdededa080 100644 (file)
@@ -61,6 +61,9 @@ XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS)
 XXXLIBS = $(LTHREAD_LIBS)
 NT_LINK_LIBS = $(LDAP_LIBLBER_LA) $(AC_LIBS) $(SECURITY_LIBS)
 UNIX_LINK_LIBS = $(LDAP_LIBLBER_LA) $(AC_LIBS) $(SECURITY_LIBS) $(LTHREAD_LIBS)
+ifneq (,$(VERSION_OPTION))
+  VERSION_FLAGS = "$(VERSION_OPTION)$(XXDIR)/libldap.map"
+endif
 
 .links : Makefile
        @for i in $(XXSRCS); do \